<template>
  <ul class="cinema-list">
    <li class="cinema-list-item" v-for="item in cinemaList" :key="item.cinemaId" @click="skipCinemaDetail(item)">
      <div class="item-address">
        <p>{{ item.name }}</p>
        <span class="center">{{ item.ticketTypes | tickets }}</span>
        <span>{{ item.address }}</span>
      </div>
      <div class="item-price">
        <p class="iconfont icon-ziyuan"></p>
        <span>{{ item.Distance | getDistance }}</span>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  name: 'CinemaReceptionistList',
  props: {
    cinemaList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  filters: {
    getDistance(value) {
      return (value + '').substr(0, 3) + '千米'
    },
    tickets(value) {
      let str = ''
      value.forEach(item => {
        str += item.name + '|'
      })
      return str.slice(0, -1)
    }
  },
  methods: {
    skipCinemaDetail(item) {
      this.$router.push(`/cinema/${item.cinemaId}`)
    }
  }
}
</script>

<style lang="scss" scoped>
.cinema-list {
  width: 100%;
  .cinema-list-item {
    padding: 0.15rem;
    border-bottom: 0.5px solid #eee;
    background: white;
    display: flex;
    justify-content: space-between;
    .item-address {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .center {
        margin: 0.1rem 0;
      }
      p {
        max-width: 2.1rem;
        color: #191a1b;
        font-size: 0.15rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      span {
        width: 2.1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #797d82;
        font-size: 0.12rem;
      }
    }
  }
  .item-price {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;

    p {
      font-size: 0.22rem;
      color: #797d82;
      margin-bottom: 0.1rem;
    }
    span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: #797d82;
      font-size: 0.12rem;
    }
  }
}
</style>